package com.example.mytestdemo.miv

import androidx.lifecycle.ViewModel
import kotlinx.coroutines.flow.MutableSharedFlow
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.SharedFlow
import kotlinx.coroutines.flow.StateFlow

/**
 * @author tgw
 * @date 2022/9/5
 * @describe
 *
 * SharedFlow与StateFlow区别
 * https://juejin.cn/post/7054178311076839432
 *
 * 传统方式
 */
class UiViewModel:ViewModel() {

    /***
     * 是否正在加载
     */
    private val isLoding = MutableSharedFlow<Boolean>()
    val _isLoding: SharedFlow<Boolean> = isLoding
    val _isLoding1: StateFlow<Boolean> = MutableStateFlow<Boolean>(false)


    /***
     * 加载成功
     */
    private val loadSuccess = MutableSharedFlow<ReqData>()
    val _loadSuccess: SharedFlow<ReqData> get() = loadSuccess


    /***
     * 加载失败
     */
    private val loadFailed = MutableSharedFlow<Exception>()
    val _loadFailed: SharedFlow<Exception>
        get() = loadFailed


    fun test(){
    }
}